﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx.TreeSharp;
using Styx;
using Action = Styx.TreeSharp.Action;
using Logger = HolySword.Helpers.LogManager;
using CommonBehaviors.Actions;
using Styx.CommonBot.Inventory;
using Styx.Pathing;
using Styx.CommonBot;
using HolySword.Helpers;

namespace HolySword.Behaviours
{
    class Resting
    {
        public static Composite DoRetribution()
        {
            return DoHoly();
        }

        public static Composite DoProtection()
        {
            return DoHoly();
        }

        public static Composite DoHoly()
        {
            return
                new Decorator(
                    ret =>                   
                    !StyxWoW.Me.IsSwimming && !StyxWoW.Me.IsGhost &&
                    StyxWoW.Me.IsAlive && !StyxWoW.Me.Mounted,
                    new PrioritySelector(
                        new Decorator(ret => StyxWoW.Me.HasAura(15007),
                                      new PrioritySelector(
                                          new Action(ret => Logger.InfoLog("Waiting for Resurrection Sickness to fade!")),
                                          new ActionAlwaysSucceed()
                                          )
                            ),
                        new Decorator(ret =>
                            Consumable.GetBestFood(true) != null &&
                            StyxWoW.Me.HealthPercent <= 40,
                            new PrioritySelector(
                                new Decorator(ret => StyxWoW.Me.IsMoving,
                                              new Action(ret => Navigator.PlayerMover.MoveStop())),
                                new Action(ret => Rest.FeedImmediate()),
                                new ActionAlwaysSucceed()
                                )
                            ),
                        new Decorator(ret =>
                            StyxWoW.Me.HealthPercent < 75,
                            new PrioritySelector(
                                Spell.BuffSelfSpell(Paladin.HolyLight,"Self Healing"),
                                new ActionAlwaysSucceed()
                                )
                            ),
                        new Decorator(ret =>
                            StyxWoW.Me.HasAura("Food") && StyxWoW.Me.HealthPercent < 95,
                            new ActionAlwaysSucceed())
                        )
                    );
        }
    }
}
